package com.lihepeng.leecode.leetcodeDataStruct.easy;

import com.lihepeng.leecode.linkedList.ListNode;
import org.junit.Test;

public class Solution83 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode cur = head;
        while(cur.next !=null){
            if (cur.value == cur.next.value){
                cur.next=cur.next.next;
            }else {
                cur = cur.next;
            }
        }
        return head;

    }
    @Test
    public void runTest(){
        ListNode listNode  = new ListNode(1);
        ListNode l1  = new ListNode(1);
        ListNode l2  = new ListNode(1);
        ListNode l3  = new ListNode(2);
        ListNode l4  = new ListNode(3);
        ListNode l5  = new ListNode(3);
        listNode.next = l1;
        l1.next = l2;
        l2.next = l3;
        l3.next = l4;
        l4.next = l5;
        ListNode listNode1 = deleteDuplicates(listNode);
        System.out.println(listNode1);
    }
}
